﻿@using AFT.Parking.WebSite.Common
@model AFT.Parking.Foundation.IPagedList<AFT.Parking.Entity.MaterialRecord>

@{
    ViewBag.Title = "机械设备管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
    <script charset="utf-8" src="/resources/scripts/ajaxfileupload.js"></script>
}

@section Head{
    <script type="text/javascript">
        function Delete(id) {
            $.ajax({
                url: "@Url.Action("Delete")",
                data:{ id: id },
                success: function (res) {
                    alert("删除成功");
                    $("#tr"+ id).remove();
                },
                error: function(res) {
                    alert("删除失败");
                }
            });
        }
    </script>
}

<div class="content-box">
    <!-- Start Content Box -->
    <div class="content-box-header">
        <h3>设备信息列表</h3>

        <div class="clear"></div>
    </div>
    <form id="frm">
        <!-- End .content-box-header -->
        <div class="content-box-content">
            <div class="tab-content default-tab" id="tab1">
                <!-- This is the target div. id must match the href of this div's tab -->
                <div class="notification attention png_bg">
                    名称：@Html.TextBox("name", null, new {@class = "searchBox"})
                    <input type="submit" class="button" id="btnSubmit" value="查询"/>
                    <div style="display: inline; float: right; margin-right: 20px; margin-top: -6px;">
                        <input type="button" class="button" id="qrcodezip" value="导出二维码" />
                        <input type="button" class="button" id="add" value="添加机械设备信息"/>
                    </div>
                </div>
                <table>
                    <thead>
                    <tr>
                        <th>名称</th>
                        <th>生产厂家</th>
                        <th>验收单位</th>
                        <th>验收日期</th>
                        <th>负责人</th>
                    </tr>
                    </thead>
                    <tfoot>
                    <tr>
                        <td colspan="6">
                            <div class="pagination">
                                @Html.Pager(Model)
                            </div>
                            <!-- End .pagination -->
                            <div class="clear"></div>
                        </td>
                    </tr>
                    </tfoot>
                    <tbody id="tBodyRows">
                    @foreach (var item in Model.Rows)
                    {
                        <tr id="@("tr" + item.Id)">
                            <td>
                                @item.MaterialName
                            </td>
                            <td>@item.ProductionCompany</td>
                            <td>@item.CheckCompany</td>
                            <td>@(item.CheckDate.HasValue?item.CheckDate.Value.ToLongDateString():"")</td>
                            <td>
                                <img src="@item.ImgUrl" style="cursor: pointer;" width="60" height="60" onclick="window.open('@item.ImgUrl')"/>
                            </td>
                            <td>
                                <a href="@Url.Action("MaterialInfoRegister")/@item.Id" title="Edit">编辑</a>
                                <a href="#" onclick="Delete(@item.Id)" title="View">删除</a>
                            </td>
                        </tr>
                    }
                    </tbody>
                </table>
            </div>
            <!-- End #tab1 -->
        </div>
        <!-- End .content-box-content -->
    </form>
</div>
@*<script>
    new AjaxUpload($("#UploadExcel"), {
        action: '@Url.Action("UpLoadExcel")',
        data: { folderName: "ConstructionExcel" },
        name: 'UploadExcel',
        responseType: "json",
        onSubmit: function(file, extension) {
        },
        onComplete: function(file, data) {
            console.log(data);
            alert(data.Message);
            if (data.Value) {
                location.href = '@Url.Action("MaterialRecordList")';
            }
        }
    });
</script>*@
<script>
    $(function() {
        //$('#template').click(function() {
        //    window.open('/DocTemplate/机械设备信息模版.xlsx');
        //});

        $('#add').click(function () {
            location.href = '@Url.Action("MaterialInfoRegister")';
        });

        $('#qrcodezip').click(function() {
            window.open('@Url.Action("ZipQrCode")');
        });
    })
</script>